﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace BDShop
{
    public class RouteConfig
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            /*Static Page*/
            routes.MapRoute(
            name: "gioi-thieu",
            url: "gioi-thieu-muasambinhdinh.html",
            defaults: new { controller = "StaticPage", action = "Introduce" }
        );

            routes.MapRoute(
           name: "dieu-khoan-mua-ban",
           url: "dieu-khoan-mua-ban.html",
           defaults: new { controller = "StaticPage", action = "Term" }
       );

            routes.MapRoute(
          name: "chinh-sach-bao-mat",
          url: "chinh-sach-bao-mat.html",
          defaults: new { controller = "StaticPage", action = "Sercurity" }
      );

            routes.MapRoute(
       name: "phuong-thuc-thanh-toan",
       url: "phuong-thuc-thanh-toan.html",
       defaults: new { controller = "StaticPage", action = "PaymentMethod" }
   );

            routes.MapRoute(
       name: "chinh-sach-doi-tra-hang",
       url: "chinh-sach-doi-tra-hang.html",
       defaults: new { controller = "StaticPage", action = "Refund" }
   );

            routes.MapRoute(
      name: "lien-he-hop-tac",
      url: "lien-he-hop-tac.html",
      defaults: new { controller = "StaticPage", action = "Collaborate" }
  );

            routes.MapRoute(
     name: "danh-sach-san-pham-yeu-thich",
     url: "danh-sach-san-pham-yeu-thich.html",
     defaults: new { controller = "Account", action = "WishList" }
 );

            routes.MapRoute(
     name: "thay-doi-mat-khau",
     url: "thay-doi-mat-khau.html",
     defaults: new { controller = "Account", action = "ChangePassword" }
 );

            routes.MapRoute(
     name: "thong-tin-tai-khoan",
     url: "thong-tin-tai-khoan.html",
     defaults: new { controller = "Account", action = "Profile" }
 );

            routes.MapRoute(
    name: "dang-ky",
    url: "dang-ky.html",
    defaults: new { controller = "Account", action = "Register" }
);

            routes.MapRoute(
   name: "dang-nhap",
   url: "dang-nhap.html",
   defaults: new { controller = "Account", action = "Login" }
);

            routes.MapRoute(
  name: "quen-mat-khau",
  url: "quen-mat-khau.html",
  defaults: new { controller = "Account", action = "ForgotPassword" }
);

            routes.MapRoute(
  name: "cap-lai-mat-khau",
  url: "cap-lai-mat-khau/{un}/{rt}",
  defaults: new { controller = "Account", action = "ResetPassword", un = UrlParameter.Optional, rt = UrlParameter.Optional }
);
            routes.MapRoute(
     name: "lich-su-dat-hang",
     url: "lich-su-dat-hang.html",
     defaults: new { controller = "Account", action = "OrderHistory" }
 );

            routes.MapRoute(
     name: "chi-tiet-don-hang",
     url: "chi-tiet-don-hang/{id}",
     defaults: new { controller = "Account", action = "OrderDetail", id = UrlParameter.Optional }
 );

            routes.MapRoute(
     name: "gio-hang",
     url: "gio-hang.html",
     defaults: new { controller = "Cart", action = "Index"}
 );

            routes.MapRoute(
    name: "thanh-toan",
    url: "thanh-toan.html",
    defaults: new { controller = "Cart", action = "Checkout" }
);

            routes.MapRoute(
     name: "loi-404",
     url: "loi-404.html",
     defaults: new { controller = "Error", action = "Error404" }
 );

            routes.MapRoute(
     name: "loi-403",
     url: "loi-403.html",
     defaults: new { controller = "Error", action = "Error403" }
 );

            routes.MapRoute(
     name: "loi-he-thong",
     url: "loi-he-thong.html",
     defaults: new { controller = "Error", action = "SystemError" }
 );
            routes.MapRoute(
             name: "san-pham-tu-khoa",
             url: "tu-khoa/{name}-{tagid}.html",
             defaults: new { controller = "Tag", action = "Index", name = UrlParameter.Optional, tagid = UrlParameter.Optional },
             constraints: new { tagid = @"(\d)+" }
         );

            routes.MapRoute(
             name: "san-pham-nha-cung-cap",
             url: "nha-cung-cap/{name}-{supid}.html",
             defaults: new { controller = "Supplier", action = "Index", name = UrlParameter.Optional, supid = UrlParameter.Optional },
             constraints: new { supid = @"(\d)+" }
         );

            routes.MapRoute(
             name: "san-pham-thuong-hieu",
             url: "thuong-hieu/{name}-{brandid}.html",
             defaults: new { controller = "Brand", action = "Index", name = UrlParameter.Optional, brandid = UrlParameter.Optional },
             constraints: new { brandid = @"(\d)+" }
         );
            /*end*/

            routes.MapRoute(
               name: "chi-tiet-san-pham",
               url: "{category}/{name}-{id}.html",
               defaults: new { controller = "Product", action = "Index", category = UrlParameter.Optional, name = UrlParameter.Optional, id = UrlParameter.Optional },
               constraints: new { id = @"(\d)+" }
           );


            routes.MapRoute(
               name: "san-pham-trong-danh-muc",
               url: "{name}-{catid}.html",
               defaults: new { controller = "Category", action = "Index", name = UrlParameter.Optional, catid = UrlParameter.Optional },
               constraints: new { catid = @"(\d)+" }
           );
            

            routes.MapRoute(
            name: "tim-kiem-san-pham",
            url: "san-pham/tim-kiem/{keyword}",
            defaults: new { controller = "Product", action = "Search", keyword = UrlParameter.Optional }
        );
            routes.MapRoute(
              name: "Product",
              url: "Product/{action}/{id}",
              defaults: new { controller = "Product", id = UrlParameter.Optional }
          );

            routes.MapRoute(
               name: "Cart",
               url: "Cart/{action}/{id}",
               defaults: new { controller = "Cart", id = UrlParameter.Optional }
           );

            routes.MapRoute(
             name: "Account",
             url: "Account/{action}/{id}",
             defaults: new { controller = "Account", id = UrlParameter.Optional }
         );

            routes.MapRoute(
                name: "Root",
                url: "{action}/{id}",
                defaults: new { controller = "Home", id = UrlParameter.Optional }
            );

            routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
            );
        }
    }
}